package com.example.changeactivity03_2;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class Act4 extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.act4);
		InitialComponet();
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.act4, menu);
		return true;
	}
	
	private void InitialComponet() {
		// TODO Auto-generated method stub
		
		yes = (Button)super.findViewById(R.id.ok);
		yes.setOnClickListener(yesBtn);
		
		no = (Button)super.findViewById(R.id.no);
		no.setOnClickListener(noBtn);

	}
	
	OnClickListener yesBtn = new OnClickListener() {
		public void onClick(View v) {
			onSelectItemClick("Yes");
		}
	};
	
	OnClickListener noBtn = new OnClickListener() {
		public void onClick(View v) {
			onSelectItemClick("no");
		}
	};
	//這個方法是自己撰寫傳送結果回去
	private void onSelectItemClick(String result){
		//要把我們選擇的結果送給管理員
		Bundle bund = new Bundle();
		bund.putString("KK", result);
		//不需要再開啟新畫面返回主畫面
		Intent intent = new Intent();
		//把結果放進去
		intent.putExtras(bund);
		setResult(1, intent);
		//結束這個畫面
		finish();
	}
	
	Button yes = null;
	Button no = null;
}
